/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * <p>Project: jse2204 - SimpleDateFormat1
 * <p>Powered by webrx On 2022-08-31 09:43:50
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class SimpleDateFormat1 {
    public static void main(String[] args) {
        //java.util.Date 日期类
        //java.util.Calendar 日历类

        //快捷代码段
        //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss S E", Locale.US);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss S E");
        Date d = new Date();
        String dstr = df.format(d);
        System.out.println(dstr);

        SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmssS");
        System.out.println(df2.format(d) + ".jpg");

        SimpleDateFormat df3 = new SimpleDateFormat("MM月dd日");
        System.out.println(df3.format(d));

        //System.out.println(printf(163,5));
        //System.out.println(printf(163,2));
        //System.out.println(printf(163, "a"));
        //System.out.println(printf(16, "a"));
        //System.out.println(printf(1412, "a"));
        //System.out.println(printf(163412, "a"));
        System.out.println(printf(12));
        System.out.println(printf(12,3));
        System.out.println(printf(12,9));
        System.out.println(printf(12,5,"#"));
        System.out.println(printf(92342349,4,'='));
    }

    public static String printf(int num,int size,char c) {
        String s = String.valueOf(c);
        return s.repeat(Math.max(size - String.valueOf(num).length(), 0)) + num;
    }

    public static String printf(int num,int size,String c) {
        return c.repeat(Math.max(size - String.valueOf(num).length(), 0)) + num;
    }

    public static String printf(int num,int size) {
        return printf(num,size,"0");
    }

    public static String printf(int num) {
        return printf(num,6,"0");
    }

    public static String printf(int num, String c) {
        return printf(num,6,c);
    }
}
